home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 5.7 KB | 115 lines | [TEXT/GEOL] |
- Item 5618045 22-Aug-88 22:07
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: D0416 Futuresoft System Design, Dev
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: re Jump Table entries
-
- Your suggestions are in the right direction. Here are some of my comments.
-
- Reallocating the global space between jump table entries and global data would
- work technically, but wouldn't be a long-term fix. The most you could have
- would be 8,000 jump table entries, at the expense of all your global data.
-
- Your second suggestion is on the right track, although I don't think it is not
- technically feasible as written. The linker cannot change a 4-byte method call
- into a 6-byte call. (It can only edit instructions in ways that don't change
- their size.)
-
- Your third suggestion is better (since it doesn't require patches to the
- Segment Loader), but you still need to have the offset into the segment
- somewhere. You could make a call be jsr xxxx(a5) to the segment-specific
- dispatcher, followed by the 2-byte offset. You would still have to make all
- calls be 6-bytes because the compiler (which determines the number of bytes in
- the call) cannot know which kind of linkage conventions to use.
-
- Your suggestions, however, only address the use of jump tables to cause
- segments to be loaded, and don't address the special circumstances of Object
- Pascal.
-
- Object Pascal method calls are different than normal subroutine calls because
- they go through a method dispatcher. Therefore, one could enhance the method
- dispatcher to also load the required code segment. Right now the method
- dispatcher uses the standard Segment Loader for this purpose. Essentialy this
- means moving the jump table entries into the method tables, and changing the
- method dispatcher to deal with loading segments. The entries in the method
- table are not accessed via indexing, so there is no limit on their number.
-
- The minimum stuff you need in a jump table entry is the code segment id and the
- offset within the segment, which amounts to 4 bytes. Normal jump table entries
- are twice that; the extra space is used to cache the absolute address of the
- code so that when the segment is already loaded the call is very fast. (The
- extra space also makes cross-segment calls much simpler.)
-
- Right now method table entries are 2 bytes, so you would double the size of the
- method tables. But you would also eliminate all the normal jump table entries
- and get a net space savings. (Note that methods cannot be called except
- through the method dispatcher, so you don't need the standard jump table
- entries.) I think you would see a performance decrease, however, because of
- the less efficient handling of the already-loaded-segment case.
-
- If method table entries were 8 bytes you could cache the abolute addresses and
- still not have a net space increase over the current implementation. You
- couldn't use the jump table format used by the Segment Loader, however. The
- Segment Loader depends on being able to quickly locate all the jump table
- entries referring to a particular segment. Without some additional storage, it
- would be fairly slow to locate all the method table entries that refer to a
- particular segment.
-
- Object Pascal also uses the jump table for 2 other purposes. (This is why
- Object Pascal programs use a lot of jump table entries.) When you make a
- method call, you need to tell the method dispatcher the method ID you are
- calling. The dispatcher gets the class ID of the object on the stack and uses
- these 2 IDs to look up the address of the method.
-
- Since the method id is 2 bytes, you would think that a method call would
- require 4 bytes for the jsr and 2 bytes for the ID. We were able to make
- method calls only 4 bytes by making the method ID be the jump table offset.
- (This also had the advantage that the linker uniquely assigns jump table
- offsets, so it would automagically assign unique method ids.)
-
- In the same way, we make the class ID be the jump table offset to the class'
- method table, so that it is easy to locate the method table.
-
- If one is willing to increase all method calls from 4 bytes to 6, then we don't
- need a jump table entry to represent the method ID. A method call would be a
- 4-byte jsr to the method dispatcher followed by a 2-byte method id. The linker
- would have to be modified to uniquely assign these ids.
-
- Alternatively, if there was a fast way to make a 2-byte subroutine call, we
- could still keep method calls at 4-bytes. An A-Trap is a 2-byte subroutine
- call, but it is not fast. (This would double the time needed to call a
- method.) The jsr(a5) instruction is fast and only 2 bytes, but the location
- pointed to by a5 is used by Quickdraw. (On the Lisa, this location was free,
- and we did use this implementation.)
-
- To summarize:
-
- If method calls were increased from 4 to 6 bytes, you could eliminate one use
- of jump table entries in Object Pascal. This saves one jump table entry per
- defined method.
-
- If the linker generates unique class IDs, then you could eliminate one jump
- table entry per class.
-
- If the method dispatcher handled segment loading, then you could eliminate one
- jump table entry per implemented method.
-
- In all cases the linker would have to be changed to generate new IDs or tables.
- The first of these changes would increase the size of programs somewhat; the
- other 2 changes would not increase the size much (if any).
-
- The compiler would also have to be changed, which impacts not only MPW Pascal,
- but also MPW C++ and TML Pascal. Also, if you change the optimized runtime
- implementation, then you can't use the ROM method dispatcher. This would slow
- down programs that execute on the Mac Plus and Mac SE.
-
-
- Larry Rosenstein
-
-
-
-